package bist.believeinstep.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import bist.believeinstep.domain.Audio;
import bist.believeinstep.util.Constant.MediaType;
import bist.believeinstep.util.Constant.State;

public class AudioMapper implements RowMapper<Audio>{

	@Override
	public Audio mapRow(ResultSet rs, int rowNum) throws SQLException {
		Audio audio = new Audio();
		audio.setId(rs.getInt("id"));
		audio.setCode(rs.getString("code"));
		audio.setName(rs.getString("name"));
		audio.setIntroduction(rs.getString("introduction"));
		audio.setDescriptions(rs.getString("descriptions"));
		audio.setLink(rs.getString("link"));
		
		String state = rs.getString("state");
		audio.setState(State.create(state));
		
		String type = rs.getString("type");
		audio.setType(MediaType.create(type));
		
		audio.setCreated(rs.getTimestamp("created_date"));
		audio.setModified(rs.getTimestamp("modified_date"));
		audio.setCreatedBy(rs.getString("created_by"));
		audio.setModifiedBy(rs.getString("modified_by"));
		
		return audio;
	}
	
}
